<!-- Replace the TITLE of template base.html -->
{% extends "base.html"%}
{% block title %}{{ post.name }}{% endblock %}

<!-- Replace the BODY of template base.html -->
{% block body %}
<h3>{{ post.title }}</h3>

<div class="row">
  <div class="col-lg-6">
    <p>Written By <a href="{{ url_for('blog.user', username=post.user.username)
      }}">{{ post.user.username }}</a> on {{ post.publish_date }}</p>
    <p>{{ post.text | safe }}</p>
  </div>
  {% if current_user.is_authenticated %}
  <div class="column">
    <div class="col-lg-2">
      <a href="{{ url_for('blog.new_post') }}" class="btn btn-primary">New</a>
    </div>
  </div>
  {% endif %}
  {% if post.user == current_user or admin_permission.can() %}
  <div class="column">
    <div class="col-lg-2">
      <a href="{{ url_for('blog.edit_post', id=post.id) }}" class="btn btn-primary">Edit</a>
    </div>
  </div>
  {% endif %}
  <div class="col-lg-12">
    <h3>New Comment:</h3>
    <!-- Set the form -->
    {# <form method="POST" action="{{ url_for('blog.post', post_id=post.id)
      }}">
      {{ form.hidden_tag() }}
      <div class="row">
        <div class="col-lg-5">
          <!-- Field: `name` label -->
          {{ form.name.label }}
          {% if form.name.errors %}
            {% for e in form.name.errors %}
              <p class="help-block">{{ e }}</p>
            {% endfor %}
          {% endif %}
          {{ form.name(class_="form-control") }}
        </div>
      </div>
      <div class="row">
        <div class="col-lg-10">
          {{ form.text.label }}
          {% if form.text.errors %}
            {% for e in form.text.errors %}
              <p class="help-block">{{ e }}</p>
            {% endfor %}
          {% endif %}
          {{ form.text(class_='form-control') }}
        </div>
      </div>
      <input class="btn btn-primary" type="submit" value="Add Comment">
    </form>
    <!-- Show the comments -->
    <div class="form-group">
      {% for comment in comments %}
        <h5>{{ comment.name }}:</h5>
        {{ comment.text }}
      {% endfor %}
    </div> #}
  <!-- duoshuo-share -->
  <div class="ds-share" data-thread-key="{{ post.id }}" data-title="{{ post.title }}" data-images="https://avatars0.githubusercontent.com/u/16975584?v=3&u=4994b2cb1d62530e95f1ef4a884fdaecb3245329&s=400" data-content="{{ post.text | truncate(100) }}" data-url="{{ url_for('blog.post', post_id=post.id )}}">
    <div class="ds-share-inline">
      <ul  class="ds-share-icons-16">
      	
      	<li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
        <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
        <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
        <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
        <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>
      	
      </ul>
      <div class="ds-share-icons-more"></div>
    </div>
  </div>
  <!-- duoshuo-comments -->
  <div class="ds-thread" data-thread-key="{{ post.id }}" data-title="{{ post.title }}" data-url="{{ url_for('blog.post', post_id=post.id) }}"></div>
  <script type="text/javascript">
    var duoshuoQuery = {short_name:"jmilkfan"};
	(function() {
		var ds = document.createElement('script');
		ds.type = 'text/javascript';ds.async = true;
		ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
		ds.charset = 'UTF-8';
		(document.getElementsByTagName('head')[0] 
		 || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
  </script>
  </div>
</div>
{% endblock %}
